from pathlib import Path
from re import compile


excl_dir_pat = [
    r'^[._]',
]
excl_dir = [compile(p) for p in excl_dir_pat]
incl_file_pat = [
    r'.*\.py$',
]
incl_file = [compile(p) for p in incl_file_pat]


def select(path='.'):
    for root, dirs, files in Path(path).walk():
        for d in dirs:
            for excl in excl_dir:
                if excl.match(d):
                    dirs.remove(d)
        for f in files:
            for incl in incl_file:
                if incl.match(f):
                    yield str(root / f)

